import request from "@/utils/request"

const perfix = "/role"


// 获取全部角色
export const getRoleList = (data) => {
  return request({
    url: `${perfix}/list`,
    method: "post",
    data
  })
}


// 添加角色
export const addRole = (data) => {
  return request({
    url: `${perfix}/add`,
    method: "post",
    data
  })
}

// 修改角色
export const updateRole = (data) => {
  return request({
    url: `${perfix}/update`,
    method: "put",
    data
  })
}

// 删除角色
export const deleteRole = (ids) => {
  return request({
    url: `${perfix}/del?ids=${ids}`,
    method: "delete"
  })
}

//根据用户id查询用户已分配的角色
export const getRolesByUserId = (userId) => {
  return request({
    url: `${perfix}/toAssign/${userId}`,
    method: 'get'
  })
}
//分配角色
export const assignRoles = (assginRoleVo) => {
  return request({
    url: `${perfix}/doAssign`,
    method: 'post',
    data: assginRoleVo
  })
}